package com.kk.bird;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * @author kzy
 * @version 1.0
 * @date 2023/2/7
 */
public class Column {
    BufferedImage image = ImageIO.read(this.getClass().getResource(GameConfig.pictureUrl+"column.png"));
    int x;
    int y;
    int width;
    int height;
    int gap;
    int distance;
    Random random = new Random();

    public Column(int n) throws Exception {
        this.width = this.image.getWidth();
        this.height = this.image.getHeight();
        this.gap = 144;
        this.distance = 245;
        this.x = 550 + (n - 1) * this.distance;
        this.y = this.random.nextInt(218) + 123;
    }

    public void step() {
        --this.x;
        if (this.x == -this.width / 2) {
            this.y = this.distance * 2 - this.width / 2;
            this.y = this.random.nextInt(218) + 132;
            this.x = 550;
        }

    }
}
